{include file="public/header" select="2" /}
<body>

<div id="app">
    <div class="title bgc">
        <i class="layui-icon layui-icon-left" onclick="load_href('{:url(\'user/index\')}',2)"></i>
        收货地址
    </div>

    <ul class="address-list">
        {foreach name="list" item="vo"}
        <li>
            <van-swipe-cell>
                <template #right>
                    <van-button data-id="{$vo.id}" square text="删除" type="danger" class="delete-button"></van-button>
                </template>
                <div class="address">
                    <div>
                        <p><a class="name">{$vo.nickname}</a> {$vo.tel} {if $vo.default == 1}<span>默认</span>{/if}</p>
                        <p>{$vo.p.title}{$vo.c.title}{$vo.d.title}{$vo.t.title}{$vo.details}</p>
                    </div>
                   <img onclick="load_href('{:url(\'address/edit\',[\'id\'=>$vo.id])}',2)" src="/static/index/img/update.png" alt="">
                </div>
            </van-swipe-cell>
        </li>
        {/foreach}

    </ul>
    <div class="pay-btn"><a href="{:url('address/add')}">+ 添加地址</a></div>
</div>
</body>
{include file="public/footer" select="0" /}
<script src="/static/index/js/vue.js"></script>
<script src="/static/index/js/vant.js"></script>
<script>
    new Vue({
        el: '#app'
    });
    $('.delete-button').click(function (e) {
        layer.confirm('确定要删除当前地址吗？', {title: '请确认'}, function (index) {
            _ajax('{:url("address/delete")}',{id:e.currentTarget.dataset.id});
        });
    })
</script>
